package com.css.fxfzysx.modules.vaolEngineering.utils;

import com.css.fxfzysx.base.response.RestResponse;
import org.apache.commons.lang3.StringUtils;

import java.util.List;

public class CheckUtil {

    /**
     * excel数据校验
     *
     * @param length 从第几行开始
     * @param size   长度
     * @param data   数据
     * @param title  表头
     * @return
     */
    public static RestResponse check(int length, int size, List<List<Object>> data, String title) {
        String[] split = StringUtils.strip(title, "[]").split(",");
        for (int i = 0; i < size; i++) {
            List<Object> objects = data.get(i);
            for (int j = 0; j < split.length; j++) {
                if (StringUtils.isBlank(objects.get(j).toString()))
                    return RestResponse.fail("第" + (i + length) + "行的{" + split[j] + "}不能为空！");
            }
        }
        return RestResponse.succeed();
    }
}
